package com.example.online_exam_system.service.impl;

import com.example.online_exam_system.entity.StuSub;
import com.example.online_exam_system.dao.StuSubDao;
import com.example.online_exam_system.service.StuSubService;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (StuSub)表服务实现类
 *
 * @author lianglong@asiainfo.com
 * @since 2021-11-25 14:38:42
 */
@Service
public class StuSubServiceImpl implements StuSubService {
    @Resource
    private StuSubDao stuSubDao;

    /**
     * 通过ID查询单条数据
     *
     * @param
     * @param userId
     * @return 实例对象
     */
    @Override
    public StuSub queryById(String userId) {
        return this.stuSubDao.queryById(userId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<StuSub> queryAllByLimit(int offset, int limit) {
        return this.stuSubDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param stuSub 实例对象
     * @return 实例对象
     */
    @Override
    public StuSub insert(StuSub stuSub) {
        this.stuSubDao.insert(stuSub);
        return stuSub;
    }

    /**
     * 修改数据
     *
     * @param stuSub 实例对象
     * @return 实例对象
     */
    @Override
    public int update(StuSub stuSub) {
        return this.stuSubDao.update(stuSub);

    }

    /**
     * 通过主键删除数据
     *
     * @return 是否成功
     */
    @Override
    public boolean deleteById() {
        return this.stuSubDao.deleteById() > 0;
    }

    @Override
    public List<Map<String, Object>> getSubjectInfo(String userId) {
        return this.stuSubDao.getSubjectInfo(userId);
    }

    @Override
    public List<Map<String, Object>> getSubjectInfo2(String userId) {
        List<Map<String, Object>> map = this.stuSubDao.getSubjectInfo2(userId);
       // return this.stuSubDao.getSubjectInfo2(userId);
        return map;

    }

    @Override
    public  List<Map<String,Object>> getTeacherSub(String teacherid) {
        return stuSubDao.getTeacherSub(teacherid);
    }

    @Override
    public int deleteTeaSub(Map<String, Object> param) {
        return stuSubDao.deleteTeaSub(param);
    }

    @Override
    public int insertTeaSub(Map<String,Object> param){
        return stuSubDao.insertTeaSub(param);
    }

    @Override
    public List<Map<String, Object>> getAllsubtea() {
        return stuSubDao.getAllsubtea();
    }

    @Override
    public int deleteTeaSubByStudentId(Map<String, Object> inParam){
        return stuSubDao.deleteTeaSubByStudentId(inParam);
    }

    @Override
    public int batchInsert(List<Map<String, Object>> list2) {
        list2.forEach(map->{
            int i = this.insert2(map);
        });
        return 1;
    }

    @Override
    public int insert2(Map<String, Object> map) {
        return stuSubDao.insert2(map);
    }

    @Override
    public List<Map<String, Object>> getReadPage() {
        return stuSubDao.getReadPage();
    }



}